how to make prime number program in efficient way